# This is necessary to use WMF5
os: unstable
install:
    - cinst -y pester
    - git clone https://github.com/PowerShell/DscResource.Tests
    - ps: Get-PackageProvider -name nuget -ForceBootStrap -Force
    # Using nuget because of issue: https://github.com/PowerShell/xNetworking/issues/5
    - ps: nuget.exe install xDscResourceDesigner -source 'https://www.powershellgallery.com/api/v2' -outputDirectory "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\" -ExcludeVersion

build: false

test_script:
    - ps: |
        $testResultsFile = ".\TestsResults.xml"
        $tempModulePath = (Resolve-Path (join-path $PWD '..')).ProviderPath
        $env:PSModulePath = "$env:PSModulePath;$tempModulePath"
        $res = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru

        (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
        if ($res.FailedCount -gt 0) {
            throw "$($res.FailedCount) tests failed."
        }
on_finish:
    - ps: |
        $stagingDirectory = (Resolve-Path ..).Path
        $zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip"
        Add-Type -assemblyname System.IO.Compression.FileSystem
        [System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFile)
        @(
            # You can add other artifacts here
            (ls $zipFile)
        ) | % { Push-AppveyorArtifact $_.FullName }
